#! /bin/bash

function get_champ_webpage {
    wget http://euw.leagueoflegends.com/champions
}

#function create_dirs {
#    for i in `grep '<a class="lol_champion"' champions | awk '{print $4}' | sed s/src=\"// | sed s/\"$// | awk -F '/' '{print $12}' | sed 's/.jpg//'`
#    do
#	mkdir ../CHAMPS/$i
#    done
#}


function get_champ_icons {
    cd /home/stefan/Coding/python/FTLoLz/CHAMPS/icons
    for i in `grep '<a class="lol_champion"' /home/stefan/Coding/python/FTLoLz/tools/champs/champions | awk '{print $4}' | sed s/src=\"// | sed s/\"$//`
    do 
	wget $i
    done
}

function get_champ_sites {

    VERSION=`grep "champions/103/ahri_the_9_tails_fox" /home/stefan/Coding/python/FTLoLz/tools/champs/champions | head -1 | awk -F '/' '{print $11}'`
    mkdir /home/stefan/Coding/python/FTLoLz/tools/champs/champ_sites/$VERSION
    cd /home/stefan/Coding/python/FTLoLz/tools/champs/champ_sites/$VERSION
    for i in `grep '<a class="lol_champion"' /home/stefan/Coding/python/FTLoLz/tools/champs/champions | awk '{print $3}' | sed s/href=\"// | sed 's/\"><img//'`
    do
	wget http://euw.leagueoflegends.com$i
    done
    cp /home/stefan/Coding/python/FTLoLz/tools/champs/champions /home/stefan/Coding/python/FTLoLz/tools/champs/champ_sites/$VERSION
}

# main

get_champ_webpage
#create_dirs
get_champ_icons
get_champ_sites



